package com.chang.cart.config;

import com.chang.cart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: changzhenxi
 * @date: 2024年12月17日 14:29
 * @Version: 1.0
 * @description: 创建拦截器之后还需要指定拦截器生效的路径，否则拦截器无效
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }
}
